********************************************************************************
** Do file: g3_loandayslocked.do
** First started: February 22, 2020
** Last edited: September 8, 2023

/* Purpose: this do file examines loans days locked percentiles

* ITEM MADE: TABLE 7
*/

********************************************************************************

clear
clear matrix
clear mata
set maxvar 10000

*** Preamble - make data sets ***

* Load repayment dataset
use "$repay_clean/fenix_repay_extend_07172020_rep", clear

* Merge in key and create a filter variable for the sample I want to analyze
merge m:1 accountid using "$merged/key_rep.dta", keepusing(k_complete_may k_rolling_list k_interacted_success k_tookloan_repay accountpercentlocked_may)
keep if _merge==3
drop _merge

g tag = 1 if k_complete_may==1 & k_rolling_list==1 & k_interacted_success==1 & k_tookloan_repay==1

tempfile all
save `all'

	
************
** PART I **
************

* Mean for the sample group, at various days

***** TABLE 7 *****

use `all', clear
keep if tag==1
sum ldl_frac if treatmenttype_sh=="R T1-L" & loandayselapsed==100, det
sum ldl_frac if treatmenttype_sh=="R T1-L" & loandayselapsed==150, det
sum ldl_frac if treatmenttype_sh=="R T1-L" & loandayselapsed==200, det
